Moving picture encoding method and decoding method

ABSTRACT

A moving picture decoding method including a prediction mode, including: in said prediction mode, in which prediction mode motion vector information of a current block in a current frame is not transmitted from an encoding side; selecting, from among multiple candidate reference frames, a frame(s) to be referenced to in the prediction mode; determining motion vector information to be used in the prediction mode, and performing prediction processing using the selected reference frame and the determined motion vector, wherein when candidate blocks within a current frame and adjacent to a current block include blocks that use forward reference frames and blocks that use backward reference frames, a forward reference frame having a smallest index number is selected as the forward reference frame for the current block from the forward reference frames that said blocks using the forward reference frames have, and a backward reference frame having a smallest index number is selected as the backward reference frame for the current block from the backward reference frames that said blocks using the backward reference frames have.

CROSS REFERENCE TO RELATED APPLICATION

This is a continuation of U.S. application Ser. No. 13/152,763 filedJun. 3, 2011, which is a continuation of U.S. application Ser. No.10/506,428, filed Mar. 9, 2005 (now U.S. Pat. No. 7,970,058), which is a371 of PCT/JP03/08843, filed Jul. 11, 2003. This application alsorelates to U.S. application Ser. No. 11/931,908, filed Oct. 31, 2007(now U.S. Pat. No. 7,936,821); U.S. application Ser. No. 11/931,978,filed Oct. 31, 2007; U.S. application Ser. No. 11/932,071, filed Oct.31, 2007 (now U.S. Pat. No. 7,936,822) and U.S. application Ser. No.11/932,110, filed Oct. 31, 2007 (now U.S. Pat. No. 7,936,823), which arecontinuations of U.S. application Ser. No. 10/506,428, filed Mar.9, 2005(now U.S. Pat. No. 7,970,058) which is a 371 of PCT/JP03/08843, filedJul. 11, 2003. This application relates to and claims priority fromJapanese Patent Application No. 2002-205001, filed on Jul. 15, 2002. Theentirety of the contents and subject matter of all of the above isincorporated herein by reference.

TECHNICAL FIELD

The present invention relates to the technology of encoding and decodingcompressed moving picture data, and particularly to the technology ofencoding and decoding on a block basis.

BACKGROUND ART

The following explains the general outlines of a moving pictureencoding/decoding method for performing encoding and decoding on a blockbasis.

As shown in FIG. 3, one frame of a moving picture consists of oneluminance signal (Y signal 61) and two color difference signals (Crsignal 62 and Cb signal 63), and each color difference signal has animage size the length and width of which are one-half of those of theluminance signal, respectively. In the common video standards, eachframe of a moving picture is divided into small blocks as shown in FIG.3, and reproduction is made in units of blocks called macroblocks. FIG.5 shows the structure of a macroblock. The macroblock consists of a Ysignal block 30 of 16×16 pixels, and a Cr signal block 31 and a Cbsignal block 31, both made of 8×8 pixels spatially matching each other.

Video coding is performed in units of macroblocks shown above. Thecoding methods are roughly divided into two types called intra coding(intra mode) and predictive coding (inter mode), respectively. Intracoding is a spatial data compression method which performs DCT on aninput macroblock image to be encoded, or an error macroblock image thattakes a difference between the input macroblock image and a predictedmacroblock image created by making a spatial prediction of the inputmacroblock image, and performs quantization and encoding on eachtransform coefficient. This intra coding is applied to macroblocks(including the first coded frame) that bear no resemblance to theirprevious frames, or portions containing accumulated arithmetic operationerrors resulting from DCT that should be resolved.

The predictive coding algorithm is called MC-DCT (MotionCompensation-Discrete Cosine Transform). Motion compensation is acompression technique for searching a reference frame for a portionsimilar to the contents of a target macroblock, and encoding the amountof motion (motion vector) along the time axis. Typically, the macroblockis further divided into smaller blocks so that a motion vector will becalculated for each smaller block. For example, MPEG-4 Part 10 (AdvancedVideo Coding) assumes macroblock partition types (luminance component)for motion compensation as shown in FIG. 7. The basics are four types 51to 54. The type 54 is divided into four 8×8 blocks 54-0 to 54-3, andformulated to further select one partition type from five types, 54 a,54 b, 54 c, 54 d, and intra coding, for each of the blocks 54-0 to 54-3.A motion vector in each smaller block is detected by selecting a portionin which the sum of absolute values of prediction error signals or thesum of squared errors is small in the block. The sum-of-absolute valuesscheme is used when the computation speed is critical, while thesum-of-squared errors scheme is used in pursuit of coding efficiency.Further, in pursuit of coding efficiency, another method may be applied,in which the amount of coding is converted to an evaluation value forthe sum-of-squared errors to calculate the optimum coding mode and theamount of motion using both the prediction error and the amount ofcoding. FIG. 4 shows the structure of motion compensation processing forone block. FIG. 4 illustrates a predicted block 75 and a motion vector76 on a previous frame 73 (reference frame) with respect to a luminancesignal block 72 surrounded by a bold border on a current frame 71. Themotion vector 76 represents the movement from a block 74 (dashed box),located spatially in the same position as the bold-bordered block on thecurrent frame, to the predicted block region 75 on the previous frame(where the length of the motion vector for each color difference signalis one-half of that for the luminance signal, and is not encoded). Afterthis motion compensation, DCT is performed on an error macroblock imagethat takes a difference between an input macroblock image and apredicted macroblock image consisting of multiple predicted blocks, andquantization and encoding are performed on each transform coefficient.The motion vector in the detected macroblock is also encoded. Sincemotion vectors of adjacent blocks have values close to each other, adifference value between the motion vectors of the adjacent blocks istypically encoded.

As motion compensation methods for predictive coding, there isbi-directionally predictive coding that performs MC using past andfuture frames as reference frames, as well as forward predictive codingthat performs MC using a past frame as a reference frame. The motioncompensation for forward predictive coding involves forward predictiononly. On the other hand, the motion compensation for bi-directionalcoding includes backward prediction, bi-directional prediction, anddirect prediction, as well as forward prediction. The bi-directionalprediction is to perform interpolation on each pixel in theforward-predicted and backward-predicted blocks, and create interpolatedpredicted blocks. The direct prediction is bi-directional predictionusing a motion vector from a future frame to a past frame along the timeaxis. In the forward, backward, or bi-directional prediction mode, amotion vector corresponding to a forward or backward motion vector ormotion vectors corresponding to forward and backward motion vectors areencoded respectively. On the other hand, it is unnecessary to encode anymotion vector in the direct mode. FIG. 9 shows the concept of predictionin the direct mode. As shown, a forward motion vector 132 from a block(collocated block 131) on a backward reference frame 130, the block 131spatially corresponding to a block 121 to be predicted on a currentframe 120, is reduced or divided into a forward motion vector 122 and abackward motion vector 123 at a ratio corresponding to the ratio ofinter-frame distances along the time axis. Using these divided motionvectors, interpolation is performed in the same manner as in thebi-directional prediction mode.

A frame in which intra coding is applied to all the macroblocks iscalled an I-picture. A frame coded using forward predictive coding orintra coding is called a P-picture. A frame coded using bi-directionalcoding or intra coding is called a B-picture.

Although the above describes commonly used encoding and decodingmethods, functions to increase the freedom of choice tend to be appliedto recent encoding and decoding methods. The following describes some ofnew functions. The use of these functions is also contemplated in MPEG-4Part 10 (Advanced Video Coding).

1. Multiple Reference Frames

The above describes that one reference frame is used for motioncompensation for a P-picture, and two reference frames, that is, a pastframe (forward reference frame) and a future frame (backward referenceframe) are used for motion compensation for a B-picture. There is alsosuch a method to prepare multiple past frames and multiple future framesas reference frames so that a different reference frame can be selectedon a macroblock basis or for each of smaller blocks into which eachmacroblock is divided. Further, the conventional methods use anI-picture or P-picture as a reference frame, whereas the new functionsallow the selection of a B-picture as a reference frame.

2. Bi-directional Reference Frame Prediction

When this method uses multiple reference frames, past frames can beincluded as possible backward reference pictures. This method alsoallows the backward reference pictures to be all past frames. Therefore,the term bi-predictive is used as a generic name for bi-directional.When both of two reference frames 140 and 150 are past frames or futureframes, the way of coding a motion vector 127 to the reference frame 150farther from a current frame is changed. As shown in FIG. 10, thehorizontal and vertical components of a difference vector 126 betweenthe motion vector 127 and a motion vector 125, which is calculated froma motion vector 124 to the reference frame 140 closer to the currentframe 121 at a ratio corresponding to the ratio of inter-frame distancesalong the time axis, are coded respectively.

3. Change of Encoding/Decoding Order

The order of frame processing has conventionally complied with such aformat as shown in FIG. 11 in which an I-picture and P-pictures areprocessed in display order, and two consecutive B-pictures arrangedbetween two I/P-pictures are processed immediately after the backwardI/P-picture on the time axis. On the other hand, the new functions arenot limited to the processing order as long as the processing is donewithin the range of allowable display delays. When the bi-predictiveconcept is used, a B-picture(s) can occur even if there is no referenceframe for backward prediction. Since the display order is coded as thedata header of video data, or managed in sync processing between videodata and audio/voice data as the upper concept of video data, acommunication layer for control of dividing and distributing data, or afile format, there occurs no display misalignment resulting from achange in encoding/decoding order.

4. Frame Identification

Information indicating the display position of each frame is coded inthe conventional. The display position information, however, may notmatch time information included in a communication packet or file formatactually used for display. To avoid this problem, a method of managingeach frame of video data using processing number only has beencontemplated. However, in a moving picture encoding/decoding system intowhich the new functions are introduced, there may be no backwardreference frame used in the direct mode, or a backward reference frameset by default from multiple backward reference frames may not be afuture frame. Such a frame cannot adapt to the direct mode. Further, ifeach frame is managed by numbers in decoding order, it cannot bedetermined whether a backward reference frame can be utilized. Inaddition, when a B-picture is selected as a backward reference frameused in the direct mode, a collocated block may have no forward motionvector. Such a block cannot adapt to the direct mode.

In view of the above problems, it is an object of the present inventionto provide an encoding/decoding method to which the direct mode can beapplied efficiently.

DISCLOSURE OF THE INVENTION

(Solution)

Information indicating whether a backward reference frame set by defaultcan be utilized in the direct mode is provided to a decoder. There isalso provided a switching procedure to switch to an alternative modeapplicable when a collocated block has no usable forward motion vector,and the alternative mode.

The present invention discloses a moving picture encoding/decodingmethod, which receives information on motion vectors, and performsmotion compensation using recorded reference images and the informationon the motion vectors to synthesize a predicted image, in which themotion compensation has multiple block modes including a mode withoutmotion vector decoding. This method includes the steps of selecting aprediction mode representing the direction(s) of prediction, selecting aframe(s) to be referred to in each direction of prediction in theprediction mode from among multiple candidate reference frames, andselecting motion vector information used in the prediction mode. Amongothers, the selection of the prediction mode may be made based onwhether blocks adjacent to a current block have a motion vector.Further, in the step of selecting a frame(s) to be referred to, onereference frame may be selected from multiple reference framesidentified by index numbers. In this case, when prediction in theselected direction is applied to the multiple adjacent blocks, areference frame used for any one of the adjacent blocks is selected,when prediction in the selected direction is applied to only one of themultiple adjacent blocks, a reference frame corresponding to the indexnumber used for the adjacent block is selected, or when the selectedprediction mode is not applied to any of the adjacent blocks, areference frame corresponding to index number 0 is selected.Furthermore, information for defining a prediction procedure performedwhen the mode without motion vector decoding is selected as a block modemay be included in a header attached on a block basis.

There are also disclosed devices and the like to which theabove-mentioned method is applied.

According to the present invention, a clear determination can be made asto whether the direct mode can be used or not. Further, the direct modeand its alternative mode can be used effectively, thereby increasingprediction efficiency and reducing the amount of data.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows an example of the data syntax of a picture header accordingto the present invention.

FIG. 2 shows a second example of the data syntax of the picture headeraccording to the present invention. FIG. 3 illustrates macroblockpartitions.

FIG. 4 illustrates the principle of motion compensation.

FIG. 5 shows the block structure used when the presence or absence ofsignificant DCT coefficients included in a macroblock is encoded.

FIG. 6 shows the structure of a macroblock as a unit of block for DCTand encoding.

FIG. 7 shows the structure of a luminance block as a unit of block formotion compensation.

FIG. 8 illustrates means for creating a predicted motion vector.

FIG. 9 shows a method of creating a motion vector for bi-directionalprediction in Direct mode.

FIG. 10 shows a method of calculating a motion vector using two forwardreference frames.

FIG. 11 shows a comparative example of decoding order and display order.

FIG. 12 shows an example of a switching procedure to switch predictionmethods according to the present invention.

FIG. 13 shows a second example of the switching procedure to switchprediction methods according to the present invention.

FIG. 14 shows the general structure of an alternative mode according tothe present invention.

FIG. 15 shows prediction mode selection in the alternative modeaccording to the present invention.

FIG. 16 shows reference frame selection in the alternative modeaccording to the present invention.

FIG. 17 shows motion vector selection in the alternative mode accordingto the present invention.

FIG. 18 shows an example of the data syntax of a prediction frameaccording to the present invention.

FIG. 19 shows an example of the structure of a universal encoding table.

FIG. 20 shows an example of code tables for P-picture based onmacroblock type and 8×8 block partition type, respectively.

FIG. 21 shows an example of code tables for B-picture based on themacroblock type and 8×8 block partition type, respectively.

FIG. 22 is a block diagram showing an example of encoding processingaccording to the present invention.

FIG. 23 is a block diagram showing an example of decoding processingaccording to the present invention.

FIG. 24 shows a third example of the data syntax of the picture headeraccording to the present invention.

FIG. 25 shows a third example of the switching procedure to switchprediction methods according to the present invention.

FIG. 26 shows an example of a prediction parameter calculator in anencoder that performs the encoding method of the present invention.

FIG. 27 shows an example of a prediction parameter calculator in adecoder that performs the decoding method of the present invention.

FIG. 28 shows an example of a software encoder that performs theencoding method of the present invention.

FIG. 29 shows an example of a software decoder that performs thedecoding method of the present invention.

FIG. 30 shows an example of an optical disk on which coded bitstreamscreated by the encoding method of the present invention are recorded.

FIG. 31 shows specific examples of devices in which theencoding/decoding method of the present invention is used.

BEST MODE FOR CARRYING OUT THE INVENTION

(Embodiment 1)

An embodiment will now be described using the accompanying drawings.

A flow of processing from a frame header to macroblock data will bedescribed in order.

FIG. 1 shows an example of frame header information. The following showsan example of processing for decoding picture header data in C-language:

picture_layer( ) { picture_structure frame_numberreference_picture_selection_layer( ) if(coding_type( )==B-picture){direct_mv_scale_bwd_dir[index]if(direct_mv_scale_bwd_dir[index]){//future directiondirect_mv_scale_bwd[index] for(index=0, index<number of forwardreference; index++){ direct_mv_scale_fwd_dir[index]if(direct_mv_scale_fwd_dir[index]){//past directiondirect_mv_scale_fwd[index]  } }  }  }

The scanning structure (frame/field) of each picture is indicated inpicture_structure 20. The identification number of the frame isspecified in frame_number 21. The way of assigning the frame_number isroughly divided into two types. One is a case where time information isincluded. In this case, for an I- or P-picture, the frame_number is aframe distance from the previous I- or P-picture, and for a B-picture,the frame_number is a frame distance from the previous I- or P-picturein the past direction (generally called a temporal reference or TR). Theother is a case where the order of decoding is simply shown.

In reference_picture_selection_layer( ), frame_number entries ofmultiple reference frames (reference picture set) usable for motioncompensation of the current frame and their identification numbers arespecified. For example, if there are five reference frames, frame_numberentries to the following index 0—index 4 are assigned to the currentframe of the frame number 10:

-   Index 0: 9-   Index 1: 8-   Index 2: 7-   Index 3: 6-   Index 4: 5    When the picture type is P-picture, the frame_number entries of the    forward reference frames (forward reference picture set) are    decoded, while when it is B-picture, the frame_number entries of the    forward and backward reference frames (forward reference picture set    and backward reference picture set) are decoded. In this case, since    the number of forward reference frames and the number of backward    reference frames can be set individually, they may be different from    each other. If the picture type is I-picture or P-picture, the    picture layer ends up with byte-align information (information for    delimiting data on a byte basis) following the reference picture set    information. Succeeding picture header data are included only when    the picture type is B-picture. In the embodiment, it is assumed that    the data are described in a layer containing high-order    network/communication related information. direct_mv_scale_bwd_dir    28 is information indicating whether the back reference frame    specified for the direct mode is located in the future or in the    past relative to the current frame. The backward reference frame    specified for the direct mode is usually a backward reference    picture assigned to the index 0. If the data 28 indicates that the    backward reference frame (the backward reference picture assigned to    the index 0 in this case) is located in the past relative to the    current frame, the direct mode cannot be used, while if the data 28    indicates that the current frame is located in the future relative    to the backward reference frame, the direct mode can be used. Thus,    the data 28 makes it possible to clearly determine whether the    direct mode can be used for the backward reference picture of the    index 0. When the direct mode cannot be performed, an alternative    mode to be described later needs applying. In the process of    preparing for the alternative mode, such as the arrangement of    memories, the efficiency of decoding can be facilitated. Further, if    the frame_number data do not include time information, information    indicating the relationship between the reference picture and the    current picture can be sent efficiently. Picture position    information related to the direct mode includes data used in modes    other than the direct mode and data that are not used in the other    modes. The latter data can be prevented from being encoded in the    direct_mv_scale_bwd_dir.

Specifically, as shown in FIG. 1, when the direct_mv_scale_bwd_dirindicates that direct mode can be used, that is, when the backwardreference frame is located in the future relative to the current frame,the data 26, 27, and 29 are encoded, while when it indicates that thedirect mode cannot be used, these data are not encoded.direct_mv_scale_bwd 29 is information specifying a frame distancebetween the current picture and the backward reference picture of theindex 0 (see FIG. 9). direct_mv_scale_fwd_dir 26 is informationindicating that the forward reference frame is located in the futurerelative to the current frame direct_mv_scale_fwd 27 is informationspecifying a picture distance between the current picture and theforward reference picture (see FIG. 9). The direct_mv_scale_fwd dataelements corresponding to the number of forward reference picturesspecified in the reference_picture_selection_layer (22) need to beencoded. However, since any forward reference frame should be located inthe past relative to the current frame, the direct_mv_scale_fwd data 27having the indexes indicating the future direction in thedirect_mv_scale_fwd_dir 26 are omitted. direct_mv_scale_divider isinformation specifying a picture distance between the backward referenceframe of the index 0 and the forward reference picture (see FIG. 9).Therefore, although all pieces of this information corresponding to thenumber of forward reference pictures need to be encoded, since theinformation can be calculated from the direct_mv_scale_fwd anddirect_reference_bwd, the encoding processing can be omitted. In thisinformation, the direct_mv_scale_fwd data 27 having the indexesindicating the future direction in the direct_mv_scale_fwd_dir 26 arealso omitted.

Even if the picture type is B-picture, the picture layer ends up withbyte-align information (information for delimiting data on a bytebasis).

The direct_mv_scale_fwd and the direct_mv_scale_bwd can also be used aspicture distance shown in FIG. 10. FIG. 2 shows the following datasyntax that expands the data syntax of FIG. 1 to include the motionvector encoding of FIG. 10.

picture_layer( ) { picture_structure frame_numberreference_picture_selection_layer( ) if(coding_type( )==B-picture){for(index=0; index<number of forward reference; index++){direct_mv_scale_fwd_dir[index] direct_mv_scale_fwd[index] } for(index=0;index<number of forward reference; index++){direct_mv_scale_bwd_dir[index] direct_mv_scale_bwd[index]  }  } }

The following describes a case where the picture type is B-picture. Inthis case, although data 26 to 29 on all the reference frames usable forthe current frame are encoded/decoded, these data can also be utilizedas picture distance information used for the motion vector encodingshown in FIG. 10. Like in FIG. 1, direct_mv_scale_bwd_dir[0] in FIG. 2functions to indicate whether the direct mode can be used or not. Adifferent point is that the combination of data 26 and 28 in FIG. 2further indicates whether the processing of FIG. 10 can be used or not.The motion vector encoding of FIG. 10 becomes effective when tworeference frames corresponding to two motion vectors are in the samedirection from the current frame. Therefore, if the values of data 26and 28 corresponding to the index numbers of the two reference picturesselected by the block are a combination of two reference frames locatedin different directions, they will be encoded/decoded individually bythe method of FIG. 8, rather than by the motion vector encoding of FIG.10. On the other hand, if the values of data 26 and 28 corresponding tothe index numbers of the two reference pictures selected by the blockare a combination of two reference frames located in the same directionfrom the current frame, the method of FIG. 10 will be applied to onemotion vector father from the current frame.

The above describes the backward reference picture used in the directionmode has index 0, but any index number other than the index 0 may beselected from the backward reference picture set as the backwardreference picture used in the direct mode. For example, when the indexnumber of the. backward reference picture used in the direct mode isspecified on the picture layer, such as the direct_reference_idx_bwd 24in FIGS. 1 and 2, the backward reference picture can be changed on ablock basis. Further, if the direct_reference_idx_bwd 24 takes on valueswith 1 added to each index number, rather than the index number itself,the value “0” can mean that the backward reference picture set includesno backward reference picture usable in the direct mode.

Referring next to a macroblock layer syntax in FIG. 18 and macroblocktype code tables in FIGS. 20 and 21, the structure of macroblock datawill be described. Some encoding methods can be adopted, such asUniversal VLC (UVLC) using only one kind of variable length code table,encoding method using a combination of fixed length coding and variablelength coding (with code tables for respective coding elements), andarithmetic coding (see “Arithmetic Coding for Data Compression” byWitten et. al., Comm. of the ACM, 30(6), 1987, pp. 520-541). In theembodiment, UVLC and arithmetic coding are taken as examples. A table 81in FIG. 11 shows the structure of UVLC, where variable Xn takes either“0” or “1”. A table 82 shows an actual example of the variable lengthcode table. A specific method for arithmetic coding may be such that themeaning of each code is replaced with several bits of binary data toencode each bit according to a probabilistic model indicating theprobability of occurrence of each bit (0 or 1). This method is calledCABAC (Context-based Adaptive Binary Arithmetic Coding).

FIG. 18 shows the syntax structure of macroblock data on B-picture.Using this figure, the following describes the structure of macroblockdata on B-picture. Note here that the description of data on I-picturewill be omitted because it is not included in the features of thepresent invention.

In FIG. 18, mb_skip_run 11 is data obtained by performing run lengthcoding.on the number of consecutive SKIP modes (that is, by coding thenumber of consecutive 0s, where when the previous macroblock is not ofSKIP mode type, the number of consecutive SKIP modes is set to zero).This data is created only when UVLC is used as an entropy coding method.The SKIP mode means the type of macroblock that uses a predicted blockimage as a block image to be reproduced without encoding of anyprediction error signal. When the picture type is P-picture, thepredicted block image is synthesized by a method for cutting out themacroblock image at a predicted vector position from the forwardreference picture having the index 0, while when it is B-picture, thepredicted block image is synthesized in the direct mode. This SKIP modeis often selected for low-rate coding, especially when the picture typeis B-picture. Therefore, the prediction performance directly. affectsthe low-rate coding performance. In the coding method using CABAC, theSKIP mode is handled in mb_type 12 without use of the mb_skip_run 11(see Code_number 0 columns in the tables 91 and 93). The mb_type 12specifies one mode selected for each macroblock from the macroblockmodes as shown in the table 91 (P-picture) or the table 93 (B-picture)so that data will be encoded in the selected mode. In the table 91, N ofIntra M×N shown in the records of code numbers 6, 7 indicates thesmaller block size for spatial prediction, and M×N indicates the smallerblock size for motion compensation (mode 1 to mode 4 in FIG. 7). TheCABAC mode in the record of code number 5 does not use N×M. In the table93, N of Intra M×N shown in the records of code numbers 23, 24 indicatesthe smaller block size for spatial prediction, and M×N indicates thesmaller block size for motion compensation (mode 1 to mode 4 in FIG. 7).Further, Direct means the direct mode (where Direct (CBP==0) is SKIPmode under the application of CABAC). The columns Block 1 an Block 2 inthe table 93 identify two smaller blocks in the mode 2 or mode 3 of FIG.7, where the direction of prediction of each smaller block is selectedfrom Forward (forward prediction), Backward (backward prediction), andBi-predictive (bi-directional reference frame prediction).

The following is additional information on the direct mode. The directmode is one of the options of the mb_skip_run 11 and the mb_type 12, butit may not be able to be applied to a system using multiple referenceframes or two references frames. Therefore, according to the presentinvention, a switching procedure to switch prediction methods accordingto the conditions is used as shown in FIG. 12. At first,direct_mv_scale_bwd_dir (FIG. 1) or direct_mv_scale_bwd_dir [0] (FIG. 2)in the picture header is checked to determine whether the direct modecan be used for the current picture (301). If it is determined in theprocessing step 301 that the direct mode cannot be used, a predictedmacroblock is created in an alternative mode (to be described in detailslater) that requires no forward MV of the collocated block (304). On theother hand, if it is determined in the processing step 301 that thedirect mode can be used, a prediction method is selected in units of 8×8blocks. Here, the prediction unit is set to 8×8 block because theminimum unit of each reference frame and the selection of predictiondirection is 8×8 block in the block partition method of FIG. 7.Specifically, it is checked whether a prediction mode that requires aforward MV is applied to the 8×8 collocated block (302). If it isdetermined that such a prediction mode is applied, a predicted block iscreated in the alternative mode (304). In the processing step 302, it isdetermined that the direct mode cannot be used when the prediction modeis the intra mode or the prediction direction of the collocated 8×8block is backward, when the value of the direct_mv_scale_fwd_dir [index]indicates that the forward reference picture is located in the backward(future) direction from the current picture, or when the forwardreference picture is not included in the forward reference picture setfor the current picture. In the processing step 302 of FIG. 12, thedetermination that the direct mode cannot be used is made in units of8×8 blocks, but it may also be made in units of macroblocks. In such acase, it is determined that the direct mode can be used only when thedirect mode is usable for all the prediction blocks in the macroblocks,that is, all the four 8×8 blocks in the block partition method of FIG.7. FIG. 13 shows a procedure to switch prediction methods when data 24is added to the picture header structure. A different point from FIG. 12is that the processing step 301 is changed to processing step 305.Specifically, the value of the data 24 is set as the index number of thedirect_mv_scale_bwd_dir.

Returning to FIG. 18, when the mb_type 12 specifies 8×8 (split), the 8×8partition data 13 is created for each of the four 8×8 smaller blocks54-0 to 54-3 shown in the mode 4 in FIG. 7. Specifically, in the 8×8Partition 18, one mode is selected for each 8×8 block from 8×8 partitionmodes shown in the table 92 (P-picture) or the table 94 (B-picture), anddata is encoded in the selected mode. In the table 92, Intra in therecord of code number 4 means Intra spatial prediction, and M×Nindicates the smaller block size for motion compensation (8×8 partition1 to 8×8 partition 4 in FIG. 7). In the table 94, Intra in the record ofcode number 13 means that the spatial prediction is applied, M×Nindicates the smaller block size for motion compensation (8×8 partition1 to 8×8 partition 4 in FIG. 7), and Direct means the direct mode. Thecolumn Prediction in the table 94 specifies the direction of predictionof each smaller block belonging to the mode 4 in FIG. 7 from Forward(forward prediction), Backward (backward prediction), and Bi-predictive(bi-directional reference. frame prediction).

Even if the direct mode is selected in the 8×8 Partition, such aprocedure to switch prediction methods as shown in FIG. 12 or 13 can beadapted. However, since the prediction performance of the direct mode inthe 8×8 Partition is less important than the direct mode MB, the methodapplied can be made simpler. For example, when it is determined in theprocessing step 302 that the collocated block has no Forward MV, apredicted block may be created by setting the Forward MV to 0 vector,and each index number of the forward reference picture and the backwardreference picture to 0, instead of the processing step 304. In thiscase, if there is no backward reference picture, the predicted block iscreated from the forward reference picture alone. Further, when it isdetermined in the processing step 302 that the collocated block has noForward MV, the decoding side may not select direct mode to make themethod much simpler.

In the case of UVLC, the mb_type 12 and the 8×8 Partition 13 are encodedby selecting, from the table 82, codes corresponding to the code numbersof the tables 91 to 94. In the case of CABAC, bitstreams indicated inthe Binarization column of the tables 91 to 94 are arithmeticallyencoded using the probabilistic model for each bit.

ref_index_fwd 14 specifies the index number of the forward referenceframe used for motion compensation, and this code is required for eachpartitioned block (51 to 54 in FIG. 7) in the macroblock. The indexnumber is selected from the forward reference picture set, but this codeis not created when the number of reference frames in the forwardreference picture set is one, when the block type or macroblock type isskip, direct, or intra, or when the direction of block prediction isbackward. This code is also not created when the code number 5 isselected as the mb_type from the table 91 for P-picture, because theforward reference picture of the index 0 is automatically selected asthe reference frame. The following considers the encoding method bytaking, as an example, a case where the forward reference picture sethas index values 0 to 4. In this example, the index 0 to the index 4 areassigned to the code numbers 0 to 4, respectively. In the case of UVLC,the codes corresponding to the code numbers 0 to 4 are selected from thetable 82 and encoded/decoded. In the case of CABAC, binary data 1′, 01′,0001′, and 00001′ are assigned to the code numbers 0 to 4, respectively,and the bitstreams are arithmetically encoded using the probabilisticmodel for each bit.

ref_index_bwd 15 specifies the index number of the backward referenceframe used for motion compensation, and this code is required for eachpartitioned block (51 to 54 in FIG. 7) in the macroblock. The indexnumber is selected from the backward reference picture set, but thiscode is not created when the picture type is P-picture, when the numberof reference frames in the backward reference picture set is one, whenthe block type or macroblock type is skip, direct, or intra, or when thedirection of block prediction is forward. Since the encoding method isthe same as the ref_index_fwd, the description will be omitted.

mvd_fwd 16 is created when the mb_type 12 and the 8×8 Partition 13indicate that the macroblock has a motion vector(s) for forwardprediction (including that in the bi-predictive mode), and repeated forthe number of forward MVs in the macroblock. Therefore, this data is notcreated when the mb_type 12 is IntraM×N, SKIP (P-picture), or Direct(B-picture), or when the 8×8 Partition 13 is Intra or Direct(B-picture). This data is also not created when the direction ofprediction of the partitioned blocks is backward (B-picture). Likewise,mvd_bwd 17 is created when the mb_type 12 and the 8×8 Partition 13indicate that the macroblock has a motion vector(s) for backwardprediction (including that in the bi-predictive mode), and repeated forthe number of backward MVs in the macroblock. Therefore, this data isnot created when the picture type is P-picture, when the mb_type 12 isIntraM×N or Direct, or when the 8×8 Partition 13 is Intra or Direct.This data is also not created when the direction of prediction of thepartitioned blocks is forward. CBP 18 is coded data indicating whetherthe 24 DCT blocks shown in FIG. 6 include 16 quantized DCT coefficientsother than “0” (significant coefficients). Residual( ) 19 is coded dataon the significant, quantized DCT coefficients. Since the blocks with nosignificant coefficients indicated in the CBP are not encoded, theResidual( )data is not created when CBP is 0. In addition, the CBP 18and the Residual( ) 19 are not created when the mb_type 12 isdirect(CBP==0).

Referring next to FIG. 8, a method of creating the above-mentionedpredicted motion vectors mvd_fwd 16 and mvd_bwd 17 will be described bytaking the partition types in FIG. 7 as examples. As shown in FIG. 7,the block 51-0 in the mode 1 (51), and the smaller blocks 54 a-0, 54 b-0and 54 b-1, 54 c-0 and 54 c-1, and 54 d-0 to 54 d-3 in the mode 4 usethe same prediction method. Suppose here that the number of smallerblocks for which motion vectors are encoded is 50. For each of thesmaller blocks, motion vectors of three adjacent blocks A, B, C areselected as candidate motion vectors, and an intermediate value of themis calculated for each of the horizontal and vertical components, thussetting the motion vector having the intermediate value as the predictedvector. The block C, however, may be uncoded block or be located outsidethe image because of their coding order or their position in themacroblock. In such a case, a motion vector of block D is used insteadof that of the block C as one of the candidate motion vectors. Further,when the blocks A and D are located outside the image, their motionvectors are set as “0” vectors to perform prediction, while when theblocks D, B, and C are located outside the image, the motion vector ofthe block A is used for prediction. If two of the three candidate blocksdo not have any motion vector, the remaining one candidate motion vectoris set as the predicted motion vector. For each of the two blocks (52-0,52-1) in the mode 2 and the two blocks (53-0, 53-1) in the mode 3 (53),motion vectors of blocks located at the base of each arrow in FIG. 8 areset as predicted values. In this motion vector coding method, only themotion vectors of the same reference frame(s) are used for prediction.Therefore, if the motion vectors of the adjacent blocks are differentfrom those of the reference frame(s) selected by the block to beencoded, the adjacent blocks are identified as being outside the image.In addition, corresponding motion vectors for the color differencecomponents are calculated by dividing the motion vector for theluminance component by 2, respectively, without encoding them.

Referring next to FIGS. 14 to 17, an alternative mode (4×4bi-predictive) that requires no Forward MV of the collocated block willbe described. The Direct mode and the Skip mode using the Direct modefor B-picture are prediction systems important to increase selectionefficiency ad encoding performance. However, systems having a highdegree of flexibility in the selection of reference frames and framecoding procedure such as MPEG-4 Part 10 cause frames and blocks forwhich the conventional Direct mode dose not function effectively. Thisalternative mode is switched to and used when the conventional Directmode does not function effectively, thereby preventing predictionperformance degradation, and hence increasing prediction efficiency.Further, the conventional Direct mode uses the motion vector of thereference frame, while the alternative mode uses the motion vector ofthe current frame. This eliminates the need to store the motion vectorin a memory for later frame encoding/decoding processing, resulting inan effective reduction in memory size. In addition, since thealternative mode does not need scaling processing for the motion vector,decoding processing can be made simpler. The prediction procedure of thealternative mode is made up of four parts shown in FIG. 14. At first,the direction of prediction is selected from bi-predictive, forward, andbackward in units of 8×8 blocks (610). This selection is made using atarget 8×8 block C 81, a block B 83 directly above the block C 81, and ablock A 82 directly on the left of the block C 81. Then, a referenceframe(s) necessary to perform the prediction mode selected in theprocessing step 610 is selected (620). This selection is made using thetarget block B 83 directly above the block C 81, and the block A 82directly on the left of the block C 81. Next, a motion vector(s)corresponding to the selected prediction mode and the reference frame(s)is calculated in units of 4×4 blocks (630). Finally, 4×4 predictedblocks are synthesized based on the prediction mode and the referenceframe(s) selected at the processing steps 610 and 620, and the motionvector(s) calculated at the processing step 630, and the indexes of thecalculated motion vector(s) and the reference frame(s) are stored formotion vector prediction (640). Since element data necessary forprediction processing are predicted from surrounding blocks in the sameframe, so that a localized motion can be predicted, thereby enhancingprediction efficiency. Further, since the alternative mode uses only thedata on the adjacent blocks in the frame, the total amount of data to bestored to perform the alternative mode can be reduced. The followingillustrates the details of this processing.

FIG. 15 shows the procedure to switch prediction methods in theprocessing step 610. At first, it is checked whether the 8×8 blockeither directly above or directly on the left has a Forward MV (611).Then, it is checked in the same manner whether the 8×8 block eitherdirectly above or directly on the left has a Backward MV (612). When the8×8 block either directly above or directly on the left has forward MVand backward MV, or when both- of the 8×8 blocks directly above anddirectly on the left do not have forward MV and backward MV,bi-predictive is selected (615). On the other hand, when the 8×8 blocksdirectly above and directly on the left have only the forward MVrespectively, forward MV is selected (616), while when they have onlythe backward MV respectively, backward MV is selected (617). Accordingto this procedure, the bi-predictive mode with the highest predictionefficiency is preferentially selected. Even when information necessaryto perform bi-predictive mode efficiently cannot be obtained from thesurrounding blocks, the direction of prediction estimated as optimalbased on the information obtained from the surrounding blocks can beselected. Further, even if sufficient information cannot be obtainedfrom the surrounding blocks, control can be done in such a manner tomake the selection of the Direct mode more effective than that of theother prediction modes, thus contributing to the improvement ofprediction efficiency. Specifically, processing in FIG. 16 andprocessing in FIG. 17 described below are combined to select thebi-predictive mode for zero vectors using forward and backward referenceframes of the index 0 (which most resemble the current frame).

FIG. 16 shows a reference frame selection procedure in the processingstep 620. This processing is performed on forward and backward referenceframes individually. Although FIG. 16 shows a case of selecting only theforward reference picture, the backward reference picture is selected inthe same manner. At first, it is checked whether both of the 8×8 blocksdirectly above and directly on the left use forward reference pictures(621). When it is determined that both of the 8×8 blocks use forwardreference pictures, one of the forward reference pictures used for thetwo 8×8 blocks is selected based on which index number is smaller (623).On the other hand, when it is determined in the processing step 621 thatat least either of the 8×8 blocks does not use a forward referencepicture, it is then checked whether the 8×8 block either directly aboveor directly on the left uses a forward reference picture (622). When itis determined in the processing step 622 that either of the 8×8 blocksuses a forward reference picture, the forward reference picture used isselected (625). On the other hand, when it is determined in theprocessing step 622 that none of the 8×8 blocks uses a forward referencepicture, the index 0 is selected (624). Thus the control is performed toselect a smaller value from the Index numbers used for encoding of theadjacent blocks. This control is done based on the fact that smallerindex numbers are assigned to frames having higher degrees of similarityto the current frame in the process of setting possible referenceframes. The index numbers are set automatically or at the time ofencoding. In the former, smaller index numbers are given to frames inthe order from the closest frame to the current frame to the farthestfrom the current frame. The latter case is applied to a moving pictureof changing scenes, for example, in such a manner to assign smallerindex numbers to frames similar in camera angle to those encoded in thepast. Thus the section of smaller index numbers increases thepossibility of selecting images similar to the frame to be processed.

FIG. 17 shows a motion vector calculation procedure in the processingstep 630. This processing is performed on forward and backward referenceframes in units of 4×4 blocks. At first, it is checked whether either a4×4 block directly above or a 4×4 block directly on the left is locatedoutside the image (631). When it is determined in the processing step631 that either of the 4×4 blocks is located outside the image, themotion vector of the 4×4 block is set .to be a zero vector (625). On theother hand, when it is determined in the processing step 631 that bothof the 4×4 blocks are located inside the image, it is then checkedwhether the 4×4 block either directly above or directly on the left hasa usable motion vector to the reference frame selected in the processingstep 620 (632). When it is determined in the processing step 632 thatnone of the 4×4 blocks has a usable motion vector to the referenceframe, the motion vector of the 4×4 block is set to be the zero vector(625). On the other hand, when it is determined in the processing step632 that either of the. 4×4 blocks has a usable motion vector to thereference frame, it is then checked whether either of the motion vectorsof the 4×4 blocks directly above and directly on the left is the zerovector to the reference frame selected in the processing step 620 (633).When it is determined in the processing step 633 that the motion vectorof either of the 4×4 blocks is the zero vector to the reference frame,the motion vector of the 4×4 block is set to be the zero vector (625).On the other hand, when it is determined in the processing step 633 thatnone of the motion vectors of the 4×4 blocks is the zero vector to thereference frame, the motion vector is calculated through prediction ofan intermediate value for the 4×4 blocks. This priority selection of thezero vector is based on the fact that the Direct mode is particularlyeffective in the background area.

The present invention includes the following modifications:

(1) In the embodiment, use of the alternative mode is decided dependingon the state of the collocated block in the manner shown in FIG. 12, butthe direct mode may be fully switched to the alternative mode. In thismethod, switching between the direct mode and the alternative mode iscontrolled in the processing step 301 on a frame or slice basis (seemodification (4) for details). This increases selection candidates toimprove adaptability to scenes with special effects, thereby improvingprediction efficiency. However, since this method may performextrapolation to calculate a motion vector between the reference frameand the current frame, such a switching control method between two modesas shown in FIGS. 12 and 13 is effective under strictly limitedconditions on the amount of computation.

(2) The processing shown in FIGS. 14 to 17 is not limited to detailedconditions as long as general principles to create the direction ofprediction, the reference frame(s), and the motion vector(s) from thesurrounding blocks are the same. For example, the present invention mayinclude a method in which the expression “the 4×4 block either directlyabove or directly on the left” in the processing step 631 is changed to“both of the 4×4 blocks directly above and directly on the left.” Thepresent invention may also include a method in which the number ofblocks used for mode selection is changed from two to three (used tocreate the predicted vector(s)). Such a method that the number of blocksused for mode selection is changed from two to three has excellentconsistency with motion vector estimation. Since such consistencyresults in the improvement of prediction efficiency, this method iseffective under the conditions without strict limitations on the amountof computation.

(3) FIGS. 1 and 2, and FIGS. 12 and 13 shows the methods in which thedirect mode is applied regardless of the index number of the forwardreference picture to the forward MV as long as the collocated block hasthe forward MV to the current frame. However, the direct mode tends tolessen its effectiveness as the forward reference picture for theforward MV moves away from the current frame. Therefore, it is effectiveto use such a method to apply the direct mode only when the index numberof the forward reference picture for the forward MV is 0. The followingdescribes this method with reference to FIGS. 24 and 25. FIG. 24 showsthe data syntax of the picture layer.

picture_layer( ) { picture_structure frame_numberreference_picture_selection_layer( ) if(coding_type( )==B-picture){direct_reference_usable if(direct_reference_usable){ direct_mv_scale_bwddirect_mv_scale_fwd } for(index=0; index<number of forward reference;index++){ picture_distance_fwd_dir[index] picture_distance_fwd[index] }for(index=0; index<number of backward reference; index++){picture_distance_bwd_dir[index] picture_distance_bwd[index] } } }

The following describes a case where the picture type is B-picture.direct_reference_usable 23 is information indicating that a backwardreference frame specified for the direct mode is located in the futurerelative to the current frame and a forward reference frame specifiedfor the direct mode is located in the past relative to the currentframe. The backward reference frame specified for the direct mode isgenerally a backward reference picture assigned to index 0, and based onthis information, it can be clearly determined whether the backwardreference picture of the index 0 can be used for the direct mode. On theother hand, the forward reference frame specified for the direct mode isgenerally a forward reference picture assigned to index 0, and based onthis information, it can be clearly determined whether the forwardreference picture of the index 0 can be used for the direct mode. If thedata 23 is 0, that is, when the backward reference picture of the index0 is located in the forward direction (past direction) from the currentpicture or the forward reference picture of the index 0 is located inthe backward direction (future direction) from the current picture, thedirect mode cannot be performed on the picture. In this case, picturedistance information necessary to apply the direct mode does not needencoding/decoding. Therefore, encoding/decoding of direct_mv_scale_fwd2427, which indicates a time interval between the current picture andthe forward reference picture of the index 0, and direct_mv_scale_bwd2429, which indicates a time interval between the current picture andthe backward reference picture of the index 0 are omitted. Data 26 to 29are data used for motion vector encoding in the bi-predictive mode shownin FIG. 10. The use of these data is described above in FIG. 2 and willnot be repeated here. Note that the direct_reference usable 23 may beinformation indicating only whether the backward reference framespecified for the direct mode is located in the future relative to thecurrent frame. In this case, information (direct_mv_scale_fwd_dir)indicating the position of the direct_mv_scale_fwd is encoded/decodedbefore the data 2427. If the forward reference picture is locatedbackward from the current picture in the case of FIG. 9, the two motionvectors 122 and 121 are calculated by extrapolation method.

Referring next to FIG. 25, handling of the direct mode will bedescribed. As described in FIGS. 12 and 13, even when the direct mode isselected as an option of the mb_skip_run 11 and the mb_type 12, it maynot be able to be applied to a system using multiple reference frames ortwo references frames. Therefore, according to the present invention, aswitching procedure to switch prediction methods according to theconditions is used. FIG. 25 shows the procedure. At first, thedirect_reference_usable 23 in the picture header is checked to determinewhether the direct mode can be used for the current picture (306). If itis determined in the processing step 306 that the direct mode cannot beused, that is, when the forward reference picture of the index 0 islocated in the future relative to the current picture or the backwardreference picture of the index 0 is located in the past relative to thecurrent picture, a predicted macroblock is created in the alternativemode that requires no forward MV of the collocated block (304). On theother hand, if it is determined in the processing step 306 thatprediction method judgment is made in units of 8×8 blocks. Here, theunit is set to 8×8 block because the minimum unit of each referenceframe and the selection of prediction direction is 8×8 block in theblock partition method of FIG. 7. Specifically, it is checked whether aprediction mode that has a Forward MV is applied to the 8×8 collocatedblock (307). If it is determined that such a prediction mode is applied,a predicted block is created in the direct mode (303). On the otherhand, if it is determined that such a prediction mode is applied, apredicted block is created in the alternative mode (304). In theprocessing step 307, it is determined that the direct mode cannot beused when the prediction mode is the intra mode or the predictiondirection of the collocated 8×8 block is backward, or when the forwardreference picture is not the reference picture of the index 0 includedin the forward reference picture set for the current picture. Like inFIG. 12, the determination of whether the direct mode can be used or notmay also be made in units of macroblocks. In such a case, however, it isdetermined that the direct mode can be used only when the direct mode isusable for all the prediction blocks in the macroblocks, that is, allthe four 8×8 blocks in the block partition method of FIG. 7. Asdescribed in FIG. 24, the direct_reference_usable 23 may indicate onlywhether the forward reference picture of the index 0 is located in thefuture relative to the current frame. In this case, motion vectors maybe calculated in the direct mode using the extrapolation methoddescribed in FIG. 24. Further, as shown in the above modification (1),the direct_reference_usable 23 may indicate only the criteria for use ofthe direct mode. In this case, when use of the direct mode is specifiedand when the forward reference picture is located in the future or thebackward reference picture is located in the future, the motion vectorsused in the direct mode of FIG. 9 are also calculated by theextrapolation method.

(4) The description of FIGS. 1 and 2, and FIG. 24 are made on the datastructure of the picture header only, but the data structure of thepresent invention can also be applied to a case where these pieces ofinformation are described in the header of a slice layer as a group ofmultiple macroblocks.

In such a system that transmits packets of compressed data in units ofslices, the procedure for decoding data is decided based on theinformation in the header of the slice layer. In this case, it isnecessary to include, in the slice header, the information of thepresent invention related to the decoding procedure. Informationindicating which macroblocks belong to one slice may be indicated in acommunication packet header for control of high-ordercommunication/network related information or the header of a fileformat, or in a sequence header that defines the entire data structure.A method of switching between the Direct mode and the alternative modeon a slice basis can increase the freedom of choice and hence predictionefficiency compared to the method of switching on a frame basis. Thismethod, however, requires selection control on a slice basis to improveprediction efficiency, resulting in an increase in the amount ofcomputation. Therefore, it can be said that control of switching on aframe basis in the frame structure is effective for use in anapplication that requires real-time processing.

The methods of the present invention described above can be applied toan image encoder/decoder using a dedicated circuit/chip, and a softwareimage encoder/decoder using a general-purpose processor.

FIG. 28 shows a portable terminal using an application processor as anexample of a built-in software encoder/decoder. The portable terminalincludes a host 2820 that mainly performs radio communicationprocessing, a camera input processor 2830 processing input signals froma camera, an application processor 2800, and an output device 2840processing display data. Upon encoding, an image photographed with thecamera is first converted by the camera input processor 2830 into a YUVsignal as shown in FIG. 3, and inputted into the application processor2800. The application processor 2800 encodes the input image into streamdata as shown in FIG. 1 (or FIG. 2 or 24) and FIG. 18. When it is of abuilt-in type, software (assembler code) that allows a processing unit2811 in the general-purpose processor 2810 to execute encodingprocessing (including the operations of FIGS. 14 to 17) is pre-stored inan internal RAM 2812 or an external RAM 2830. Also pre-allocated in theinternal RAM 2812 or the external RAM 2830 are memory areas for dataused in prediction processing as shown in the flowcharts of FIGS. 14 to17 (such as multiple reference pictures, reference picture numbers foreach macroblock, prediction direction, and motion vectors). Thearrangement of the memory areas for the assembler code and the data isdesigned in consideration of balance among processor performance, busrate, estimated access frequencies to the assembler code or each data,and their data sizes. In general, the internal RAM provides fasteraccess than the external RAM, while the external RAM is larger incapacity than the internal RAM. Therefore, data areas with higher accessfrequency but of small size, and the assembler code are arranged in theinternal RAM. The assembler code may be divided between the internal RAMand the external RAM. The coded bitstreams data are stored in theexternal RAM 2830 or a memory in the host 2820. In other words, they arestored in either the external RAM or the host memory, depending on theservices for the portable terminal such as the use of the codedbitstreams data. Upon decoding, the bitstreams data are supplied fromthe host 2820 or the external RAM 2830 to the application processor2800. The application processor 2800 decodes the coded bitstreams datainputted, converts the YUV reproduced image into RGB images, and outputsthe RGB images to the output device 2840. In this processing, the YUVreproduced image may be temporarily accumulated in a frame memory of theexternal RAM or internal RAM. Like in the encoding processing, software(assembler code) that allows the processing unit 2811 in thegeneral-purpose processor 2810 to execute decoding processing (includingthe operations of FIGS. 14 to 17) is prestored in the internal RAM 2812or the external RAM 2830. Also pre-allocated in the internal RAM 2812 orthe external RAM 2830 are memory areas for data used in predictionprocessing as shown in the flowcharts of FIGS. 14 to 17 (such asmultiple reference pictures, reference picture numbers for eachmacroblock, prediction direction, and motion vectors).

FIG. 29 shows an example of a software encoder/decoder for more generalpurpose use. Upon encoding, an input image is accumulated in a framememory 22950 from which a general-purpose processor 2900 readsinformation to execute encoding processing. -A program (including theoperations shown in the flowcharts of FIGS. 14 to 17) for operating thegeneral-purpose processor is read out of a storage device 2930, such asa hard disk or floppy disk, and stored in a program memory 22920. Codedinformation outputted from the general-purpose processor is temporarilystored in an I/O buffer 2940, and then outputted as coded bitstreams.Data used in prediction processing as shown in the flowcharts of FIGS.14 to 17 (such as multiple reference pictures, reference picture numbersfor each macroblock, prediction direction, and motion vectors) arestored in a processing memory 22910 from or into which thegeneral-purpose processor reads or stores data according to the program.Upon decoding, a coded bitstreams inputted is temporarily stored in theI/O buffer 2940 from which the general-purpose processor reads anddecodes the coded bitstreams. A program (including the operations shownin the flowcharts of FIGS. 14 to 17) for operating the general-purposeprocessor is read out of the storage device 2930, such as a hard disk orfloppy disk, and stored in the program memory 22920. A decoded image istemporarily stored in the frame memory 22950, and then outputted to anoutput device. Data used in prediction processing as shown in theflowcharts of FIGS. 14 to 17 (such as multiple reference pictures,reference picture numbers for each macroblock, prediction direction, andmotion vectors) are stored in the processing memory 22910 from or intowhich the general-purpose processor reads the data or stores createddata according to the program.

FIG. 22 shows the structure of an image encoder using a dedicatedcircuit/chip. The following describes the flow of encoding processingfor one macroblock. At first, a motion compensator 211 performs motioncompensation between an input macroblock image 201 and a decoded imageof a coded frame (reference frame) stored in a frame memory 2210 for allmacroblock types (8×8 Partition type) and all combinations of candidatereference frames to select the optimum macroblock type and 8×8 Partitiontype. In this case, if the motion compensation is performed in theDirect mode, the motion compensator 211 needs to acquire information onprediction direction, reference frame numbers, and motion vectors froman MV estimator 215. FIG. 26 shows the internal structure of the MVestimator. When the macroblock type (8×8 Partition type) indicating theDirect mode, macroblock position information (block positioninformation), and the type of direct mode (direct/alternative, controlby the motion compensator, or the alternative prediction mode indicatedin FIGS. 14 to 17) are inputted into the MV estimator, a switcher 2630is turned on through a switcher 2620. The switcher 2630 switches modesaccording to the type of direct mode. When the direct mode is of directpredictive type, a motion vector calculator 2660 is activated. Themotion vector calculator 2660 calculates prediction parameters shown inFIG. 9 using information stored in an internal memory 22610. Theparameters calculated are not only stored in the internal memory, butalso notified to the motion compensator. When the direct mode is ofalternative predictive type, an alternative estimator 2640 is activated.The alternative estimator 2640 performs processing shown in FIG. 14.Specifically, a prediction mode selector 2641, a reference frameselector 2642, and a motion vector selector 2643 perform processingshown in FIGS. 15, 16, and 17, respectively, using the informationstored in the internal memory 22610 to determine the direction ofprediction, the reference frame number, and the motion vector. Theseprediction parameters are not only stored in the internal memory, butalso notified to the motion compensator.

Returning to the motion compensator, a motion vector(s) detected afterselection of the optimum macroblock type is notified to the MV estimator215 together with the macroblock type, the prediction directioninformation (forward/backward/bi-predictive), and the reference framenumber(s) to update the contents of the internal memory 22610 (wherewhen the direct mode is selected, only the macroblock type or 8×8Partition type is updated). For blocks other than those of which themacroblock type and the 8×8 Partition type are not direct, the motionvector estimator 2650 (activated by the switcher 2620) performsprediction processing shown in FIG. 8 to calculate a difference motionvector, respectively. The calculated difference motion vector isoutputted to a multiplexer 206 together with the macroblock type, the8×8 Partition type, and the reference frame number (where when thedirect mode is selected, the difference motion vector and the referenceframe number are not multiplexed). It is assumed here that thedifference motion vector is calculated only for the optimum macroblocktype (8×8 Partition type), but the value of the difference motion vectorand the amount of encoding may also be used as an evaluation value forselection of the optimum macroblock type (8×8 Partition type). In such acase, the MV estimator calculates a difference motion vector for all themacroblock type (8×8 Partition type) and all combinations of referenceframes, respectively.

A predicted macroblock image 213 cut out from the reference framecreated through the motion compensation is inputted into an Intra/Interjudgment processor 214. The Intra/Inter judgment processor makes a finaldecision on which mode, intra or inter, will be the macroblock type, andnotifies the multiplexer 206 and the MV estimator 215 of judgmentinformation 218. When the judgment information 218 is the intra mode,the MV estimator 215 updates the data stored in the internal memory. Themultiplexer creates a set of codes as shown in FIG. 18, from theIntra/Inter mode judgment result, and the macroblock type, the 8×8Partition type, the reference frame number, and the difference motionvector obtained from the MV estimator (where when the direct mode isselected, the difference motion vector and the reference frame numberare not included), and multiplexed the set of codes into a codedbitstreams. When the macroblock type selected by the Intra/Interjudgment processor is the inter mode, the predicted macroblock image isprocessed by a differentiator 202 so that it will be differentiated fromthe input macroblock image 201 of the current frame, and a differencemacroblock image is created. In this case, the predicted macroblockimage is also outputted to an adder 209 at the same time. On the otherhand, when the macroblock type selected by the Intra/Inter judgmentprocessor is the intra mode, no predicted macroblock is outputted to thedifferentiator 202 and the adder 209.

The difference macroblock image outputted from the differentiator 202,or the input macroblock image is first DCT-transformed. Although theblock size of DCT is generally an 8×8 block of pixels in theconventional encoding systems, since the transform of 4×4 pixel size hasrecently been contemplated, such as MPEG-4 Part 10 (Advanced VideoCoding), the following describes 4×4 DCT by way of example. As shown inFIG. 6, the difference macroblock image is divided into 4×4 blocks ofpixels, and transformed by a DCT transformer 203 into a total of 16 DCTcoefficients. Each DCT coefficient is quantized by a quantizer 204, andencoded by the multiplexer 206. The multiplexer 206 multiplexesmacroblock data as shown in FIG. 18 with header information as shown inFIG. 1, 2, or 24 to create a coded bitstreams. The quantized DCTcoefficients are decoded by an inverse DCT transformer 208 into thedifference macroblock image or the input macroblock image. When themacroblock prediction mode is the inter mode, the difference macroblockimage is added by the adder 209 to the predicted macroblock image, andthen synthesized in the frame memory 2201. On the other hand, when themacroblock prediction mode is the intra mode, the reconstructedmacroblock image is synthesized in the frame memory 2201.

Although intra prediction is not performed in the intra mode in FIG. 22,the present invention can also be applied to an encoding mode performingintra prediction. In such a case, the Intra/Inter judgment processor mayperform intra prediction, or this processing may be incorporated intothe motion compensator. In particular, such an encoding system thatprovides multiple intra prediction modes, such as MPEG-4 Part 10(Advanced Video Coding), can handle inter and intra prediction modesconcurrently, thereby streamlining the device structure. In such a case,the difference predicted macroblock image 213 is always supplied fromthe motion compensator 211 to the differentiator 202 and the adder 209.Further, since the judgment information 218 is included in themacroblock type information, the judgment information 218 can beeliminated, and the internal memory updating processing performed by theMV estimator 215 in conjunction with input of the judgment information218 can also be omitted. In addition, the intra prediction may beperformed in the DCT coefficient level. In such a case, the predictionprocessing can be incorporated into the DCT transformer 203 and the IDCTtransformer 208.

FIG. 23 shows the structure of an image decoder using a dedicatedcircuit/chip. The following describes the flow of decoding processingfor one macroblock. At first, a code decoder 501 analyzes input codeddata, and assigns motion vector related information and macroblock typeinformation to an MV estimator 508, and quantized DCT coefficientinformation to an inverse quantizer 502.

When the macroblock prediction mode is the inter mode, the blockposition information, the macroblock type, the 8×8 Partition type, theprediction direction information, the reference frame number, and thedifference motion vector are inputted into the MV estimator 508 (wherewhen the macroblock type is the direct mode, only the macroblock typeand the macroblock position information are inputted, or when the 8×8Partition type is direct, the reference frame number and the differencemotion vector for the 8×8 block are not inputted). FIG. 27 shows theinternal structure of the MV estimator. When the macroblock type or 8×8Partition type is direct, the type of direct mode (direct/alternative,or control by the motion compensator) in slice header informationdecoded by the code decoder 501 are inputted into the MV estimatortogether with the macroblock position information and the block positioninformation. In response to input of the macroblock position information(block position information) and the type of direct mode(direct/alternative, or control by the motion compensator), the switcher2630 is turned on through the switcher 2620. The switcher 2630 switchesmodes according to the type of direct mode. When the direct mode is ofdirect predictive type, a motion vector calculator 2660 is activated.The motion vector calculator 2660 calculates prediction parameters shownin FIG. 9 using information stored in an internal memory 22710. Theparameters calculated are not only stored in the internal memory, butalso notified to the motion compensator 504. When the direct mode is ofalternative predictive type, the alternative estimator 2640 isactivated. The alternative estimator. 2640 performs processing shown inFIG. 14. Specifically, the prediction mode selector 2641, the referenceframe selector 2642, and the motion vector selector 2643 performprocessing shown in the flowcharts of FIGS. 15, 16, and 17,respectively, using the information stored in the internal memory 22710to determine the direction of prediction, the reference frame number,and the motion vector. These prediction parameters are not only storedin the internal memory 22710, but also notified to the motioncompensator 504. On the other hand, when the macroblock type (8×8Partition type) is not direct, the macroblock position information(block position information), the reference number, and the differencemotion vector are inputted together with the macroblock type (8×8Partition type). In response to input of the data, the switcher 2620activates a motion vector predictor 2750. The motion vector predictor2750 performs prediction processing shown in FIG. 8 using the contentsof the internal memory 22710 and the input data to reconstruct themotion vector. The reconstructed motion vector is outputted to theinternal memory 22710 and the motion compensator 504 together with theprediction direction information and the reference frame number. Themotion compensator 504 creates a predicted macroblock image using theinput data and the reference frame stored in a frame memory 2507. Next,the inverse quantizer 502 and an inverse DCT transformer 503 performinverse quantization and inverse DCT on coded data related to aprediction error signal on a 4×4-pixel-block basis, respectively, toreconstruct the difference macroblock image. Then, an adder 505 adds thepredicted macroblock image and the difference macroblock image toreproduce the macroblock, and synthesizer 506 synthesizes the reproducedmacroblock image with a decoded frame image. The decoded frame image isstored in a frame memory 2507 for prediction of the next frame.

When the macroblock type is the intra mode, the inverse quantizer 502and the inverse DCT transformer 503 perform inverse quantization andinverse DCT on the decoded quantized DCT coefficient information on a4×4-pixel-block basis, respectively, to reproduce the macroblock image.At this time, the contents of the internal memory 22710 are updated inthe intra mode. Although intra prediction is not performed in thisfigure, the present invention can also be applied to such an encodingsystem that provides multiple intra prediction modes, such as MPEG-4Part 10 (Advanced Video Coding). In such a case, the motion compensator504 has the intra prediction function to always output a predictivemacroblock image.

FIG. 30 shows an example of a storage medium (recording medium) on whichthe coded bitstreams created by the software encoder (FIGS. 14 to 17)shown in FIGS. 28 and 29 or by the encoder of FIGS. 22 and 26 isrecorded. Digital information is recorded concentrically on a recordingdisk (magnetic disk or optical disk) 3000 capable of recording thedigital information. In a part 3001 of the digital information recordedon the disk, slice header information 3010 including direct/alternativemode selection information (direct_reference_usable) 3011, SKIP modeinformation (mb_skip_run) 3021, 3031, 3041, and 3051, macroblock typeinformation (mb_type, 8×8 partition) 3022, 3032, and 3052, informationon reference frame numbers and motion vectors (ref_index_few,ref_index_bwd, mvd_fwd, mvd_bwd) 3023 and 3053, and DCT coefficients andcoding block pattern information (CBP, residual( ) 3024 and 3054 arerecorded. The following describes the data structure of the slice headerwhen the frame type is B-picture and the direct mode is alternative.3021 to 3024 and 3051 to 3054 are coded data on macroblocks other thanthose of which the macroblock type is not Direct. Such a case that atleast one 8×8 Partition type includes direct takes the same datastructure. In this case, since information on reference frame numbersand motion vectors related to 8×8 blocks of which the 8×8 Partition typeis direct is not encoded, these kinds of information are not included in3023 or 3053. Therefore, upon decoding, the prediction direction, thereference frame number, and the motion vector are calculated as shown inFIGS. 14 to 17 in the case of the software decoder, or by the processingmeans 2640 of FIG. 27 in the case of the dedicated decoder. Acombination of 3031, 3032, and 3035 denotes coded data on macroblocks ofwhich the macroblock type is direct. In this case, the information onreference frame numbers and motion vectors is not encoded. Therefore,upon decoding, the prediction direction, the reference frame number, andthe motion vector are calculated as shown in FIGS. 14 to 17 in the caseof the software decoder, or by the processing means 2640 of FIG. 27 inthe case of the dedicated decoder. 3041 is an example of skip macroblockof which the macroblock type is direct. In this case, there is no DCTcoefficient information. Therefore, upon decoding, the predictiondirection, the reference frame number, and the motion vector arecalculated as shown in FIGS. 14 to 17 in case of the software decoder,or by the processing means 2640 of FIG. 27 in case of the dedicateddecoder, and a predicted macroblock image synthesized from these data isused as it is as a reproduced macroblock image. Thus, since the codesindicating that the macroblock type is the direct mode are embedded onthe storage medium efficiently, a reproduced macroblock image can besynthesized from a smaller amount of information.

FIG. 31 shows specific examples of devices for implementing theencoding/decoding method of the present invention.

The decoding method of the present invention can be loaded into areproduction device 3102 that reads and decodes coded bitstreamsrecorded on an optical disk 3101 (DVD-ROM, DVD-R, BD-ROM or Blue-rayDisc, ROM, CD-ROM/CD-R, etc.) as a recording medium. In this case, thereproduced picture signal is displayed on a TV monitor 3103.

The coding method of the present invention can be loaded into arecording/reproduction device 3112 that encodes ground-based orsatellite digital broadcasting programs received via an antenna 3111 torecord coded bitstreams on an optical disk 3113 (DVD-RAM, DVD-RW,BD-RAM, CD-RW, etc.). The decoding method of the present invention canalso be loaded into the recording/reproduction device 3112 that decodesthe coded bitstreams recorded on the optical disk 3113. In this case,the reproduced picture signal is displayed on a TV monitor 3114.

A software program for the image encoding/decoding method of the presentinvention can also be installed on a computer 3121 so that the computerwill function as an image encoder/decoder. The software program isrecorded on any kind of storage medium 3122 (optical disc, floppy disk,hard disk, etc.) as a computer-readable recording medium. The personalcomputer reads and uses the software program. Further, the personalcomputer can be connected to any communication line so that it can beused as a video communication terminal.

Further, the decoding method of the present invention can be loaded intoa decoder in a set-top box 3132 connected to a cable 3131 for cable TVor an antenna for satellite or ground-based digital broadcast so thatdigital broadcasting programs will be replayed on a TV monitor 3133. Thedecoding method of the present invention may be incorporated into adecoder in the TV monitor, rather than in the set-top box.

Furthermore, a device including the encoding/decoding method of thepresent invention or the software encoder/decoder of the presentinvention can be mounted in a digital portable terminal 3141. There arethree mounting forms: a two-way terminal having both the encoding methodand decoding method, a transmitter terminal having the decoding functiononly, and a receiver terminal having the decoding function only.

Furthermore, the encoding/decoding method of the present invention canbe incorporated into a video camera 3151. In this case, the video cameraincludes a decoder and a recorder for recording output-of the decoder ona recording medium. The recorder records, on the recording medium, codedbitstreams outputted from the coder. If the above portable terminal hasa camera, photographed images can be encoded and transmitted through theantenna.

Furthermore, the encoding/decoding method of the present invention canbe incorporated into a video conferencing system 3161 having a camerainput. A picture inputted from the camera is encoded at an encoder intoa coded bitstreams and distributed to a network 3162. The codedbitstreams received from the network is decoded at a decoder anddisplayed on a monitor. In this case, means for implementing theencoding/decoding method of the present invention may be a softwareencoder/decoder rather than the encoder/decoder.

The encoding/decoding method of the present invention can beincorporated in the above-mentioned devices in such a manner to make aneffective use of the direct mode and the alternative mode, therebyimproving predictability.

The header information according to the present invention makes itpossible to clearly determine whether the direct mode can be used ornot. Further, when the frame number has no time information, informationindicating the relationship between the reference frame and the currentframe can be sent efficiently. In addition, the alternative mode and theswitching procedure to switch to the alternative mode make it possibleto improve predictability even if the direct mode cannot be applied.

Industrial Applicability

The present application can be applied to encoding/decoding of movingpictures.

1. A moving picture decoding method including a prediction mode,comprising: in said prediction mode, in which prediction mode motionvector information of a current block in a current frame is nottransmitted from an encoding side; selecting, from among multiplecandidate reference frames, a frame(s) to be referenced to in theprediction mode; determining motion vector information to be used in theprediction mode, and performing prediction processing using the selectedreference frame and the determined motion vector, wherein when candidateblocks within a current frame and adjacent to a current block includeblocks that use forward reference frames and blocks that use backwardreference frames, a forward reference frame having a smallest indexnumber is selected as the forward reference frame for the current blockfrom the forward reference frames that said blocks using the forwardreference frames have, and a backward reference frame having a smallestindex number is selected as the backward reference frame for the currentblock from the backward reference frames that said blocks using thebackward reference frames have.